<template>
    <div class="studentBaseInfo">
      <el-breadcrumb separator="/" class="breadcrumb-bottom">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>活动管理</el-breadcrumb-item>
        <el-breadcrumb-item>活动列表</el-breadcrumb-item>
        <el-breadcrumb-item>活动详情</el-breadcrumb-item>
      </el-breadcrumb>

      <el-form :model="studentInfoSearchForm" :rules="rules" ref="studentInfoSearchForm" label-width="0px">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item prop="">
              <el-input v-model="studentInfoSearchForm.className" placeholder="请输入班级名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item prop="">
              <el-input v-model="studentInfoSearchForm.studentId" placeholder="请输入学生学号"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item prop="">
              <el-input v-model="studentInfoSearchForm.studentName" placeholder="请输入学生名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6" class="overflow-clear">
            <el-button type="primary" @click="submitForm('studentInfoSearchForm')" class="float-right">立即搜索</el-button>
          </el-col>
        </el-row>
      </el-form>
      <hr>

      <div>
        <div class="float-left table-title-before">
          学生基本信息管理
        </div>
        <el-button-group style="margin-bottom:4px;" class="float-right">
          <el-button type="primary"><router-link to="/StudentPersonInfo">新增学生</router-link></el-button>
          <el-button type="primary">导入数据</el-button>
          <el-button type="primary">导出数据</el-button>
        </el-button-group>
      </div>

      <el-table
        :data="studentTable"
        border
        style="width: 100%">
        <el-table-column
          prop="studentID"
          label="学号"
          width="180">
        </el-table-column>
        <el-table-column
          prop="studentName"
          label="姓名"
          width="180">
        </el-table-column>
        <el-table-column
          prop="studentSex"
          label="性别"
          width="180">
        </el-table-column>
        <el-table-column
          prop="classID"
          label="班级"
          width="180">
        </el-table-column>
        <el-table-column
          prop="studentJob"
          label="职务"
          width="180">
        </el-table-column>
        <el-table-column
          prop="studentPhoto"
          label="联系方式"
          width="180">
        </el-table-column>

        <el-table-column
          label="地址">
          <template scope="scope">
            <router-link to="/StudentPersonInfo"><i class="el-icon-edit"></i></router-link>
            <router-link to="" @click.native.prevent="deleteRow(scope.$index, studentTable)"><i class="el-icon-delete"></i></router-link>
          </template>
        </el-table-column>
      </el-table>

      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage4"
        :page-sizes="[100, 200, 300, 400]"
        :page-size="100"
        layout="total, sizes, prev, pager, next, jumper"
        :total="400">
      </el-pagination>
    </div>
</template>
<style>
</style>
<script>
    export default{
        name : 'studentBaseInfo',
        data(){
            return{
                studentInfoSearchForm:{
                    className: '',
                    studentId: '',
                    studentName: ''
                },
                studentTable:[
                ],
            }
        },
        components:{
        },
        mounted:function(){
            this.$nextTick(function(){
              this.res();
            })
        },
        methods:{
            res:function(){
                // GET /someUrl
                this.$http.get('http://localhost:8080/TeachingMIS/studentBaseInfo/getStudent?page=1').then(response => {
                  // get body data
                    for (const element of response.body){
                         this.studentTable.push(element);
                    }
                      //push to tableData[]

                      console.log(element);
                  }
                , response => {
                  // error callback
                  alert("no file page");
                });
            },
            deleteRow:function(index, rows) {
              rows.splice(index, 1);
            },
            submitForm(formName) {
              this.$refs[formName].validate((valid) => {
                if (valid) {
                  alert('submit!');
                } else {
                  console.log('error submit!!');
                  return false;
                }
              });
            }
        }
    }
</script>
